<?php

namespace App\Exceptions;

use Exception;
use Throwable;

class HttpResponseException extends Exception
{
    /**
     * 常用错误提示
     * @var array $message
     */
    protected $message = [
        1 => ['type' => 'error_mysql', 'message' => '操作失败，数据崩溃啦~']
    ];
    /**
     * 主动抛出错误
     * @param string|int $message
     * @param int        $code
     * @param Throwable  $previous
     */
    public function __construct($message, $code = 0, Throwable $previous = null)
    {
        $message = is_numeric($message)
            ? isset($this->message[$message]) ? $this->message[$message]['message'] : ''
            : $message;
        parent::__construct($message, $code, $previous);
    }
}
